(function(){
	//Private variables
	var mapDiv,
		map,
		centerLon = -64.423444488507, //CENTER - Definidos para Argentina
		centerLat = -41.105773412891,
		maxZoomOut = 4;

	var headID = document.getElementsByTagName("head")[0];         

	//Inserto la librería OpenLayers
	var openlayers = document.createElement('script');
	openlayers.type = 'text/javascript';
	// openlayers.onload=scriptLoaded;
	openlayers.src = '/lib/OpenLayers.js';
	headID.appendChild(openlayers);

	function scriptLoaded () {
		// socket = io.connect(connectionURL);
	};

	//Tickmap
	var tickmapOL = {
		//Div que contiene el mapa
		setMapDiv: function(divId) {
			mapDiv = divId;
		},

		initMap: function () {
			map = new OpenLayers.Map(mapDiv, {
		        units : 'm',
		        projection : new OpenLayers.Projection('EPSG:4326'),
		        displayProjection : new OpenLayers.Projection("EPSG:4326")
		    });

		    map.addControl(new OpenLayers.Control.LayerSwitcher());

		    //Create a base layers
		    var gphy = new OpenLayers.Layer.Google(
		        "Google Physical",
		        {type: google.maps.MapTypeId.TERRAIN}
		    );
		    var gmap = new OpenLayers.Layer.Google(
		        "Google Streets", // the default
		        {numZoomLevels: 20}
		    );
		    var ghyb = new OpenLayers.Layer.Google(
		        "Google Hybrid",
		        {type: google.maps.MapTypeId.HYBRID, numZoomLevels: 20}
		    );
		    var gsat = new OpenLayers.Layer.Google(
		        "Google Satellite",
		        {type: google.maps.MapTypeId.SATELLITE, numZoomLevels: 22}
		    );

		    map.addLayers([ghyb, gmap, gsat, gphy]);
		    map.setCenter(new OpenLayers.LonLat(centerLon, centerLat).transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")), maxZoomOut);
		}
	};
	if(!window.tickmapOL){window.tickmapOL=tickmapOL;}//We create a shortcut for our framework
})();